import { createRouter, createWebHistory } from 'vue-router'


const router = createRouter({
  history: createWebHistory(import.meta.env.BASE_URL),
  routes: [
    {
      path: '/index',
      name: 'index',
      component: () => import('../views/index.vue'), 
      children:[
        {
          path: '/index/agreement',
          name: 'agreement',
          component: () => import('../views/index/agreement.vue'), 
      
      },
      {
        path: '/index/agreedetail',
        name: 'agreedetail',
        component: () => import('../views/index/agreedetail.vue'), 
      },
      {
        path: '/index/agreechange',
        name: 'agreechange',
        component: () => import('../views/index/agreechange.vue'), 
      },
      {
        path: '/index/agreeadd',
        name: 'agreeadd',
        component: () => import('../views/index/agreeadd.vue'), 
      },
      {
        path: '/index/money',
        name: 'money',
        component: () => import('../views/index/money.vue'), 
      },
      {
        path: '/index/orderManage',
        name: 'orderManage',
        component: () => import('../views/index/orderManage.vue'), 
      },
      {
        path: '/index/projectManage',
        name: 'projectManage',
        component: () => import('../views/index/projectManage.vue'), 
      },
      {
        path: '/index/goodPerson',
        name: 'goodPerson',
        component: () => import('../views/index/goodPerson.vue'), 
      },
      
      {
        path: '/index/home',
        name: 'home',
        component: () => import('../views/index/home.vue'), 
    
    },
      ]

      
  },
  {

  path: '/login',
  name: 'login',
  component: () => import('../views/login.vue')
  },
  {

    path: '/register',
    name: 'register',
    component: () => import('../views/register.vue')
    },

  {
    path:"/",
    redirect:"/index"
  }
  ]

})


// router.beforeEach((to,from,next)=>{
//   var token = localStorage.getItem('token');
//  if (to.path == '/login'){
//     if(token){
//       next('/index/home')

//     }else{
//       next();
//     }
//   }else{
//     if(token){
//       next()
//     }else{
//        next('/login')
//     }
//   }

//   next()
// })

export default router
